package com.sdo.qihang.gprogress.lib;

import android.content.Context;
import android.graphics.Canvas;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.View;

public class GProgress extends android.support.v7.widget.AppCompatSeekBar {
    private GProgressHelper mGProgressHelper;

    public GProgress(Context context, AttributeSet attrs) {
        this(context, attrs, 0);
        mGProgressHelper = new GProgressHelper(this, context, attrs, 0);
    }

    public GProgress(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
        mGProgressHelper = new GProgressHelper(this, context, attrs, defStyle);
    }

    @Override
    protected synchronized void onMeasure(int widthMeasureSpec,
                                          int heightMeasureSpec) {
        int width = MeasureSpec.getSize(widthMeasureSpec);
        int height = mGProgressHelper.measureHeight(heightMeasureSpec);
        setMeasuredDimension(width, height);
        mGProgressHelper.measure();
    }

    @Override
    protected synchronized void onDraw(Canvas canvas) {
        mGProgressHelper.drawProgress(canvas);
    }

    @Override
    public boolean onTouchEvent(MotionEvent event) {
        if (mGProgressHelper.isSlideEnable()) {
            return super.onTouchEvent(event);
        } else {
            return true;
        }
    }

    public boolean isSlideEnable() {
        return mGProgressHelper.isSlideEnable();
    }

    public void setSlideEnable(boolean mSlideEnable) {
        mGProgressHelper.setSlideEnable(mSlideEnable);
    }

    public int getTextColor() {
        return mGProgressHelper.getTextColor();
    }

    public void setTextColor(int mTextColor) {
        mGProgressHelper.setTextColor(mTextColor);
    }

    public int getTextSize() {
        return mGProgressHelper.getTextSize();
    }

    public void setTextSize(int mTextSize) {
        mGProgressHelper.setTextSize(mTextSize);
    }

    public int getReachedProgressBarHeight() {
        return mGProgressHelper.getReachedProgressBarHeight();
    }

    public void setReachedProgressBarHeight(int mReachedProgressBarHeight) {
        mGProgressHelper.setReachedProgressBarHeight(mReachedProgressBarHeight);
    }

    public int getReachedBarColor() {
        return mGProgressHelper.getReachedBarColor();
    }

    public void setReachedBarColor(int mReachedBarColor) {
        mGProgressHelper.setReachedBarColor(mReachedBarColor);
    }

    public int getUnReachedBarColor() {
        return mGProgressHelper.getUnReachedBarColor();
    }

    public void setUnReachedBarColor(int mUnReachedBarColor) {
        mGProgressHelper.setUnReachedBarColor(mUnReachedBarColor);
    }

    public int getUnReachedProgressBarHeight() {
        return mGProgressHelper.getUnReachedProgressBarHeight();
    }

    public void setUnReachedProgressBarHeight(int mUnReachedProgressBarHeight) {
        mGProgressHelper.setUnReachedProgressBarHeight(mUnReachedProgressBarHeight);
    }

    public boolean isIfDrawText() {
        return mGProgressHelper.isIfDrawText();
    }

    public void setIfDrawText(boolean mIfDrawText) {
        mGProgressHelper.setIfDrawText(mIfDrawText);
    }

    public int getSlidePadding() {
        return mGProgressHelper.getSlidePadding();
    }

    public void setSlidePadding(int mSlidePadding) {
        mGProgressHelper.setSlidePadding(mSlidePadding);
    }

    public int getSlideBorderColor() {
        return mGProgressHelper.getSlideBorderColor();
    }

    public void setSlideBorderColor(int mSlideBorderColor) {
        mGProgressHelper.setSlideBorderColor(mSlideBorderColor);
    }

    public int getSlideLineColor() {
        return mGProgressHelper.getSlideLineColor();
    }

    public void setSlideLineColor(int mSlideLineColor) {
        mGProgressHelper.setSlideLineColor(mSlideLineColor);
    }

    public int getProgressOverMax() {
        return mGProgressHelper.getProgressOverMax();
    }

    public void setProgressOverMax(int mProgressOverMax) {
        mGProgressHelper.setProgressOverMax(mProgressOverMax);
    }
}
